package com.wx.mall.operate.controller;

import com.wx.mall.common.api.CommonResult;
import com.wx.mall.operate.dto.RebLinkDto;
import com.wx.mall.operate.entity.RebLink;
import com.wx.mall.operate.service.impl.RebLinkServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author z
 * @since 2020-6-4
 */
@RestController
@RequestMapping("/reb/link")
public class RebLinkController {

    @Autowired
    RebLinkServiceImpl rebLinkService;

    @ApiOperation(value = "类型查询全部")
    @GetMapping("/getSortLink")
    public CommonResult<List<Long>> findRebSortLink(Long ids){
        List<Long> findSort = rebLinkService.getFindSort(ids);
        return CommonResult.success(findSort);
    }

    @ApiOperation(value = "类型添加修改")
    @PostMapping("/getUpdateLink")
    public CommonResult<RebLink> getUpdateLink(RebLinkDto dto){
        int sortLink = rebLinkService.getSortLink(dto);
        return sortLink==1?CommonResult.success():CommonResult.failed();
    }

}
